package com.reciver.util;

import java.util.Date;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import com.reciver.common.util.DateUtil;

public class DateUtils {

	/**
	 * @param minute 负分钟
	 * @return 获取多少分钟之前的时间
	 **/
	public static String getBeforeTime(int minute) {
		Calendar beforeTime = Calendar.getInstance();
		beforeTime.add(Calendar.MINUTE,minute);//30分钟之前的时间
		Date beforeD = beforeTime.getTime();
		return DateUtil.formatTime(beforeD);
	}
	public static String getBeforeHour() {
		Calendar calendar = Calendar.getInstance();
		/** HOUR_OF_DAY 指示一天中的小时 */
		calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-3);
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return df.format(calendar.getTime());
	}
	public static String getBeforeDay(int days) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
		calendar.add(Calendar.DATE,-days);
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return df.format(calendar.getTime());
	}
}